﻿using System;
using System.Reflection;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping.ByCode;

namespace GroceryList.Front.Web.Helpers
{
    public class NhMappingHelper
    {
        public static HbmMapping GetCompiledMappingFromAssembly(Type typeInsideAssembly)
        {
            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetAssembly(typeInsideAssembly).GetExportedTypes());
            return mapper.CompileMappingForAllExplicitlyAddedEntities();
        }
    }
}